-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --json flag for resource-class cmds #1088
base: develop
Are you sure you want to change the base?
Add --json flag for resource-class cmds #1088
Conversation
4b4fb83
to
5ecaaae
Compare
@jdelnano Yeah, it's an unauth to a context. That's a set of secrets which may be being used by CCI to access their vuln vendor, and they would have assigned a user or groups to that context which you aren't in. Not 100% sure, but does infer open source contributors can't fully run PRs ourselves. I'm sure our CCI friends will take a peek! |
Ref: circleci-cli/.circleci/config.yml Lines 359 to 360 in 08776cb
|
thanks @jdelnano for this - will give it a review thanks @adamharvey-okta for helping out here as well to give @jdelnano that context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
Relates to #380
Checklist
=========
Internal Checklist
Not applicable to me, a non-CircleCI employee
Changes
=======
Implementation
I implemented my changes in the following way:
--json
flag to theresource_class.go
file where it was appropriate to, for thecreate
andlist
command actions.--json
flag was set on the command line, and if so, we Marshal the appropriate object and set it in the Writer interface offered by the cobracmd
object.circleci runner resource-class list <>
circleci runner resource-class create <>
they will behave exactly as they did. Only if you include a
--json
flag will you see new behavior, returned to stdout.Automated Tests
I made sure to add tests in
resource_class_test.go
where appropriate as well as update the expected usage files.Manual Tests
I executed the following commands manually (alongside the automated testing), to ensure:
Rationale
=========
Background
In my position at Okta, a CircleCI customer, I have a few automation tasks that require the use of the
circleci runner resource-class list
andcircleci runner resource-class create
commands, where I specifically need to grab the output of these commands and do subsequent actions. As a result, my motivation for adding the--json
flag support for thecircleci runner resource-class
command is to return more easily parsable output, instead of the default ASCII table format.Potential Future Work
If this PR is accepted, and it is deemed advantageous, I can move this new
--json
flag to be global/applicable so that other CLI commands can return JSON formatted responses to stdout.